<template>
    <div class="container">
        <el-row class="wrap-search">
            姓名：
            <el-input v-model="configList.param.trueNameLike" placeholder="请输入"></el-input>
            <el-button @click="getList()" type="primary" size="medium">查询</el-button>
        </el-row>
        <div class="table">
            <table-list ref="tableList" :tableConfig='configList'>
                <el-table-column  slot="image"  align="center" label="头像">
                    <template slot-scope="scope">
                        <img class="video-img" style="width: 60px;height: 60px;border-radius: 50%" @click="imgClick(scope.row.images.length ? scope.row.images[0].fileUrl : '')" :src="scope.row.images.length ? scope.row.images[0].fileUrl : ''" alt="">
                    </template>
                </el-table-column>
                <el-table-column  slot="sex"  align="center" label="性别">
                    <template slot-scope="scope">
                        <div v-if="scope.row.sex == 1">男</div>
                        <div v-else>女</div>
                    </template>
                </el-table-column>
                <el-table-column  slot="duty"  align="center" label="认证身份">
                    <template slot-scope="scope">
                        <div>{{dutyConvert(scope.row.duty)}}</div>
                    </template>
                </el-table-column>
                <el-table-column  slot="area"  align="center" label="地区">
                    <template slot-scope="scope">
                        <div>{{scope.row.province}}{{scope.row.city}}{{scope.row.district}}</div>
                    </template>
                </el-table-column>
                <el-table-column  slot="department"  align="center" label="科室">
                    <template slot-scope="scope">
                        <div>
                            {{departmentConvert(scope.row.department)}}
                        </div>
                    </template>
                </el-table-column>
                <el-table-column  slot="title"  align="center" label="职称">
                    <template slot-scope="scope">
                        <div>{{titleConvert(scope.row.title)}}</div>
                    </template>
                </el-table-column>
                <el-table-column class="btn" label="操作" slot="btn" align="center" min-width="200">
                    <template slot-scope="scope">
                        <div class="flex-box-justify">
                            <el-button  class="search-btn" size="small" type="primary" @click="handleClickWatch(scope.row.id)">查看</el-button>
                            <div v-if="scope.row.duty == 'doctor || nurse || recover_physical_therapist || health_manager' || 'apothecary'">
                                <el-button  class="search-btn" size="small" type="primary" @click="handleClickVisit(scope.row.id)">出诊情况</el-button>
                            </div>
                            <el-button  class="search-btn" size="small" type="danger" @click="delLevel(scope.row.id)">删除</el-button>
                        </div>
                    </template>
                </el-table-column>
            </table-list>
        </div>
    </div>
</template>

<script>
    let CONSTANT = require('../../constant/constant.js');
    let common = require("../../common.js");
    export default {
        data() {
            return {
                sectionList: [
                    {key: "fu", value: "妇科"},
                    {key: "er", value: "儿科"},
                    {key: "nei", value: "内科"},
                    {key: "quan", value: "全科"},
                    {key: "hu_xi", value: "呼吸科"},
                    {key: "xin_nei", value: "心内科"},
                    {key: "xiao_hua", value: "消化科"},
                    {key: "gan_bing", value: "肝病科"},
                    {key: "shen_zang", value: "肾脏科"},
                    {key: "nei_fen_mi", value: "内分泌科"},
                    {key: "shen_jing_nei", value: "神经内科"},
                    {key: "feng_shi_mian_yi", value: "风湿免疫科"},
                    {key: "zhong_liu", value: "肿瘤科"},
                    {key: "xue_ye", value: "血液科"},
                    {key: "pi_fu", value: "皮肤科"},
                    {key: "ru_xian", value: "乳腺科"},
                    {key: "nan", value: "男科"},
                    {key: "teng_tong", value: "疼痛科"},
                    {key: "lao_nian_bing", value: "老年病科"},
                    {key: "zhou_wei_xue_guan", value: "周围血管科"},
                    {key: "gu_shang", value: "骨伤科"},
                    {key: "zhong_yi_yi_nan_bing", value: "中医疑难病科"},
                    {key: "zhen_jiu", value: "针灸科"},
                    {key: "zhi_wei_bing", value: "治未病科"},
                    {key: "tui_na", value: "推拿科"},
                    {key: "wu_guan", value: "五官科"},
                    {key: "yan", value: "眼科"},
                    {key: "er_bi_hou", value: "耳鼻喉科"},
                    {key: "gang_chang", value: "肛肠科"},
                    {key: "kou_qiang", value: "外科"},
                    {key: "wai_shen_jing", value: "外神经科"},
                    {key: "mi_niao_wai", value: "泌尿外科"},
                    {key: "ji_zhen", value: "急诊科"},
                    {key: "sheng_zhi", value: "生殖科"},
                    {key: "kang_fu", value: "康复科"},
                    {key: "mei_rong", value: "美容科"},
                    {key: "xin_li", value: "心理科"},
                    {key: "xin_shen_yi_xue", value: "心身医学科"},
                    {key: "ti_jian_zhong_xin", value: "体检中心科"},
                    {key: "yao_ji", value: "药剂科"},
                    {key: "yi_wu", value: "医务科"},
                    {key: "ying_yang", value: "营养科"},
                ],
                positionList: [
                    {key: "doctor_one", value: "主任医师"},
                    {key: "doctor_two", value: "副主任医师"},
                    {key: "doctor_three", value: "主治医师"},
                    {key: "doctor_four", value: "医师"},
                    {key: "doctor_five", value: "执业药师"},
                    {key: "doctor_six", value: "药士"},
                    {key: "doctor_seven", value: "药师"},
                    {key: "doctor_eight", value: "主管药师"},
                    {key: "doctor_nine", value: "助理医师"},
                    {key: "doctor_eleven", value: "中医师"},
                    {key: "doctor_tweleve", value: "康复理疗师"},
                    {key: "doctor_thirteen", value: "健康管理师"},
                    {key: "doctor_fourteen", value: "执业护士"}
                ],
                checkList: [
                    {key: "doctor", value: "医生"},
                    {key: "nurse", value: "护士"},
                    {key: "recover_physical_therapist", value: "康复理疗师"},
                    {key: "health_manager", value: "健康管理师"},
                    {key: "apothecary", value: "药师"},
                    {key: "hospital", value: "医院"},
                    {key: "clinic", value: "诊所"},
                    {key: "drugstore", value: "药店"},
                    {key: "medical_instrument_supplie", value: "医疗器械供应商"},
                ],
                configList:{
                    url:CONSTANT.URL.DOCTOR.DOCTORLIST,
                    configList:[
                        {
                            slot:'image'
                        },
                        {
                            label: "姓名",
                            prop: "trueName"
                        },
                        {
                            slot: "sex"
                        },
                        {
                            slot: "duty"
                        },
                        {
                            slot: "area"
                        },
                        {
                            label: "医疗机构",
                            prop: "company"
                        },
                        {
                            slot: "department"
                        },
                        {
                            slot:'title'
                        },
                        {
                            slot:'btn'
                        }
                    ],
                    param:{
                        trueNameLike: "",
                    },
                    type:'',
                    width:'',
                    isPagination:true
                },
                dialogVisible:false,
                dialogVisible1:false,
                imgUrl:'',
                upLoadUrl:'',
                dataList:[]
            }
        },
        components: {
            'table-list':() => import('../common/my-table')
        },
        mounted() {
        },
        computed: {

        },
        methods: {
            getList(){
                this.$refs.tableList.getList()
            },
            imgClick(url){
                this.imgUrl = url;
                this.dialogVisible = true;
            },
            delLevel(id){
                this.$confirm('确定删除?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    let  url = CONSTANT.URL.DOCTOR.DOCTORDELETE,
                        param = {id:id}
                    common.requestAjax(url,{},param,(res)=>{
                        if(res.status == 200){
                            this.$message({
                                type: 'success',
                                message:res.msg
                            });
                            this.getList();
                        }else{
                            this.$message({
                                message: res.msg,
                                type: 'warning'
                            });
                        }
                    })

                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            handleRemove(file, fileList) {      // 图片上传
                let deleteUrl = file.url;
                let list = this.information.images;
                list.forEach(function(item,index){
                    if(item.fileUrl == deleteUrl){
                        list.splice(index,1);
                    }
                })
                console.log(list);
                this.information.images = list;
            },
            handlePictureCardPreview(file) {
                this.dialogImageUrl = file.url;
                this.dialogVisible = true;
            },
            handleFileSuccess(res, file) {
                if(res.status == 200){
                    let picItem = res.data.bussData;
                    this.information.images.push(picItem);
                    this.fileListChange();
                }
            },

            handleClickWatch(id) {
                this.$router.push({path: "/doctor/detail", query: {id:id}})
            },
            handleClickVisit(id) {
                this.$router.push({path: "/doctor/inquiry", query: {id:id}})
            },
            dutyConvert(duty) {
                if (duty) {
                    let dd = "";
                    this.checkList.map( item => {
                        if (item.key == duty) {
                            dd = item.value
                        }
                    })
                    return dd;
                } else {
                    return ""
                }
            },
            departmentConvert(department) {
                if (department) {
                    let dd = "";
                    this.sectionList.map( item => {
                        if (item.key == department) {
                            dd = item.value
                        }
                    })
                    return dd;
                } else {
                    return ""
                }
            },
            titleConvert(title) {
                if (title) {
                    let dd = "";
                    this.positionList.map( item => {
                        if (item.key == title) {
                            dd = item.value
                        }
                    })
                    return dd;
                } else {
                    return ""
                }
            }
        }
    }
</script>

<style lang="scss">
    .container {
        .wrap-search {
            margin-bottom: 20px;
            .el-input {
                width: 20%;
            }
        }
        .table {
            .cell {
                .el-button {
                    margin-right: 10px;
                    &:nth-child(3) {
                        margin-right: 0;
                    }
                }
            }
        }
    }
</style>
